/**
 * PFontLoader.java ##copyright## This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option) any later version.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details. You should have received a copy of the GNU Lesser
 * General Public License along with this library; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * 
 * @author ##author##
 * @modified ##date##
 * @version ##version##
 */

package fiveagon.loader;

import java.io.File;

import processing.core.PApplet;
import processing.core.PFont;

/**
 * <code>Loader</code> for Processing fonts (VLW).
 * <p>
 * Implementation of <code>Loader&lt;PFont&gt;</code>. All calls to <code>load</code> will return a
 * <code>List&lt;PFont&gt;</code>.
 * </p>
 */
public class PFontLoader extends AbstractLoader<PFont> {
  private final PApplet parent;

  /**
   * Constructor for general use. This <code>Loader</code> will load from the sketch's default data
   * folder.
   * 
   * @param parent a reference to the sketch, usually passed with <code>this</code>.
   * @throws IllegalArgumentException if the sketch's default data folder does not exist.
   */
  public PFontLoader(PApplet parent) {
    super(parent);
    this.parent = parent;
  }

  @Override
  protected boolean isLoadable(File file) {
    return file.getName().endsWith(".vlw");
  }

  @Override
  protected PFont loadElement(File file) {
    return parent.loadFont(file.getName());
  }
}
